/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Pattern;

import java.util.ArrayList;

/**
 *
 * @author David
 */
public class NameList {

    private ArrayList<String> names;
    private SortStrategy sortAlgorithm;

    public NameList(SortStrategy strategy) {
        this.sortAlgorithm = strategy;
        names = new ArrayList<>();
    }

    public void addName(String name) {
        names.add(name);
    }

    public void printList() {
        sortAlgorithm.sort(names);
        for (String name : names) {
            System.out.println(name);
        }
    }

    public void printList(SortStrategy newStrategy) {
        this.sortAlgorithm = newStrategy;
        printList();

    }
}
